package coml.jiyun.hp.wanandroid.ui.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import coml.jiyun.hp.wanandroid.R;
import coml.jiyun.hp.wanandroid.bean.SquareBean;

public class RlvSquareAdapter extends RecyclerView.Adapter<RlvSquareAdapter.ViewHolder> {

    private Context context;
    private List<SquareBean.DataBean.DatasBean> datasBeans = new ArrayList<>();

    public RlvSquareAdapter(Context context) {
        this.context = context;
    }


    public void setDatasBeans(List<SquareBean.DataBean.DatasBean> datasBeans) {
        this.datasBeans = datasBeans;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_rlv_square, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        SquareBean.DataBean.DatasBean datasBean = datasBeans.get(position);
        holder.mTv1.setText(datasBean.getShareUser());
        holder.mTv2.setText(datasBean.getNiceShareDate());
        holder.mTv3.setText(datasBean.getTitle());
        holder.mTv4.setText(datasBean.getSuperChapterName()+"·广场");
    }

    @Override
    public int getItemCount() {
        return datasBeans.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        TextView mTv1;
        TextView mTv2;
        TextView mTv3;
        TextView mTv4;
        ImageView mImg;

        public ViewHolder(View itemView) {
            super(itemView);

            mTv1 = itemView.findViewById(R.id.item_square_tv1);
            mTv2 = itemView.findViewById(R.id.item_square_tv2);
            mTv3 = itemView.findViewById(R.id.item_square_tv3);
            mTv4 = itemView.findViewById(R.id.item_square_tv4);
            mImg = itemView.findViewById(R.id.item_square_img);

        }
    }
}
